<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML><HEAD><TITLE>Man page of XBEE_SETUP</TITLE>
</HEAD><BODY>
<H1>XBEE_SETUP</H1>
Section: Linux Programmer's Manual (3)<BR>Updated: 02-Mar-2012<BR><A HREF="#index">Index</A>
<A HREF="../index.html">Return to Main Contents</A><HR>

<A NAME="lbAB">&nbsp;</A>
<H2>NAME</H2>

xbee_setup, xbee_vsetup, xbee_validate, xbee_shutdown
<A NAME="lbAC">&nbsp;</A>
<H2>SYNOPSIS</H2>

<B>#include &lt;<A HREF="file:///usr/include/xbee.h">xbee.h</A>&gt;</B>

<P>
<B>xbee_err xbee_setup(struct xbee **</B><I>retXbee</I><B>, const char *</B><I>mode</I><B>, ...);</B>

<P>
<B>xbee_err xbee_vsetup(struct xbee **</B><I>retXbee</I><B>, const char *</B><I>mode</I><B>, va_list </B><I>ap</I><B>);</B>

<P>
<B>xbee_err xbee_validate(struct xbee *</B><I>xbee</I><B>);</B>

<P>
<B>xbee_err xbee_shutdown(struct xbee *</B><I>xbee</I><B>);</B>


<A NAME="lbAD">&nbsp;</A>
<H2>DESCRIPTION</H2>

<P>
The functions
<B>xbee_setup</B>() and <B>xbee_vsetup</B>()

start an instance of libxbee.
<I>retXbee</I>

is the returned pointer to the libxbee instance.
<I>mode</I>

specifies which mode should be started. Three modes are currently provided and supported:

<PRE>
'<B>xbee1</B>'   the mode used for Series 1 XBee modules
'<B>xbee2</B>'   the mode used for Series 2 XBee modules
'<B>xbee3</B>'   the mode used for Series 3 XBee modules
'<B>xbee5</B>'   the mode used for Series 5 XBee modules (868 MHz)
'<B>xbee6b</B>'  the mode used for Series 6B XBee modules (Wi-Fi)
'<B>xbeeZB</B>'  the mode used for ZigBee XBee modules
'<B>net</B>'     the network client
'<B>debug</B>'   the debugger
</PRE>


<P>
Each mode can require different initialization parameters, which are provided by the 
<I>...</I> or <I>ap</I> arguments.

The arguments for the modes listed above are detailed below in the 'Modes' section.
<P>
<B>xbee_validate</B>()

allows you to confirm that your handle points to a valid libxbee instance.
<P>
<B>xbee_shutdown</B>()

will terminate all remaining connections and free all data associated with the instance of libxbee.
<A NAME="lbAE">&nbsp;</A>
<H3>Modes</H3>

'<B>xbee1</B>', '<B>xbee2</B>', '<B>xbee3</B>', '<B>xbee5</B>', '<B>xbee6b</B>' and '<B>xbeeZB</B>'

- these modes require two parameters:

<B>char *</B>device             e.g: 

&quot;/dev/ttyUSB0&quot;
<P>
<B>int </B>  baudrate           e.g:

57600


<P>
'<B>net</B>'

- this mode required two parameters:

<B>char *</B>hostname           e.g:

&quot;localhost&quot;, &quot;127.0.0.1&quot;
<P>
<B>int </B>  port               e.g:

27015


<P>
'<B>debug</B>'

- this mode required one parameter:

<B>char *</B>target_mode        e.g:

&quot;xbee1&quot;


<A NAME="lbAF">&nbsp;</A>
<H3>Return Value</H3>

On success these functions will return XBEE_ENONE, otherwise an error number from
<I>enum xbee_errors</I> (as specified in <I>&lt;<A HREF="file:///usr/include/xbee.h">xbee.h</A>&gt;</I>)

<A NAME="lbAG">&nbsp;</A>
<H2>EXAMPLE</H2>

To setup libxbee with a Series 1 XBee, using /dev/ttyUSB0 at 57600 baud:
<P>

<PRE>
#include &lt;<A HREF="file:///usr/include/xbee.h">xbee.h</A>&gt;

xbee_err ret;
struct xbee *xbee;

if ((ret = xbee_setup(&amp;xbee, &quot;xbee1&quot;, &quot;/dev/ttyUSB0&quot;, 57600)) != XBEE_ENONE) {
        printf(&quot;xbee_setup(): %d - %s\n&quot;, ret, xbee_errorToStr(ret));
        return ret;
}

/* use libxbee */

if (xbee_shutdown(xbee) != XBEE_ENONE) return;
</PRE>


<A NAME="lbAH">&nbsp;</A>
<H2>AUTHOR</H2>

Attie Grande &lt;<A HREF="mailto:attie@attie.co.uk">attie@attie.co.uk</A>&gt; 
<A NAME="lbAI">&nbsp;</A>
<H2>SEE ALSO</H2>

<B><A HREF="../man3/libxbee.3.html">libxbee</A></B>(3),

<B><A HREF="../man3/xbee_modeGetList.3.html">xbee_modeGetList</A></B>(3),

<B><A HREF="../man3/xbee_conGetTypes.3.html">xbee_conGetTypes</A></B>(3),

<B><A HREF="../man3/xbee_conNew.3.html">xbee_conNew</A></B>(3),

<B><A HREF="../man3/xbee_attachEOFCallback.3.html">xbee_attachEOFCallback</A></B>(3)

<P>

<HR>
<A NAME="index">&nbsp;</A><H2>Index</H2>
<DL>
<DT><A HREF="#lbAB">NAME</A><DD>
<DT><A HREF="#lbAC">SYNOPSIS</A><DD>
<DT><A HREF="#lbAD">DESCRIPTION</A><DD>
<DL>
<DT><A HREF="#lbAE">Modes</A><DD>
<DT><A HREF="#lbAF">Return Value</A><DD>
</DL>
<DT><A HREF="#lbAG">EXAMPLE</A><DD>
<DT><A HREF="#lbAH">AUTHOR</A><DD>
<DT><A HREF="#lbAI">SEE ALSO</A><DD>
</DL>
<HR>
This document was created by
<A HREF="/cgi-bin/man/man2html">man2html</A>,
using the manual pages.<BR>
Time: 18:19:28 GMT, September 04, 2013
</BODY>
</HTML>
